using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using AtletIS.DomainModel.Entities.Web;
using AtletIS.DomainModel.Entities.Main;
using AtletIS.Database.Mapping.Web;
using AtletIS.Database.Mapping.Main;

namespace AtletIS.Database.Context
{
    public partial class AtletisContext : DataContext
    {
        static AtletisContext()
        {
            System.Data.Entity.Database.SetInitializer<AtletisContext>(null);
        }

        public AtletisContext() 
            : base("Name=AtletisDbContext")
        {
        }

        #region DbSets

        //public DbSet<Article> Articles { get; set; }
        //public DbSet<ArticlesCategory> ArticlesCategories { get; set; }
        //public DbSet<Category> Categories { get; set; }
        //public DbSet<Club> Clubs { get; set; }
        //public DbSet<ClubsGroup> ClubsGroups { get; set; }
        //public DbSet<Competition> Competitions { get; set; }
        //public DbSet<Competitor> Competitors { get; set; }
        //public DbSet<Contact> Contacts { get; set; }
        //public DbSet<Country> Countries { get; set; }
        //public DbSet<DisciplineList> DisciplineLists { get; set; }
        //public DbSet<Discipline> Disciplines { get; set; }
        //public DbSet<DisciplinesGroup> DisciplinesGroups { get; set; }
        //public DbSet<DisciplinesStatus> DisciplinesStatuses { get; set; }
        //public DbSet<Document> Documents { get; set; }
        //public DbSet<DocumentsCategory> DocumentsCategories { get; set; }
        //public DbSet<DocumentsSubcategory> DocumentsSubcategories { get; set; }
        //public DbSet<ExtText> ExtTexts { get; set; }
        //public DbSet<CheckPoint> CheckPoints { get; set; }
        //public DbSet<ChipData> ChipDatas { get; set; }
        //public DbSet<ChipTag> ChipTags { get; set; }
        //public DbSet<ChipTagsGroup> ChipTagsGroups { get; set; }
        //public DbSet<Link> Links { get; set; }
        //public DbSet<LinksCategory> LinksCategories { get; set; }
        //public DbSet<Performance> Performances { get; set; }
        //public DbSet<ResultCode> ResultCodes { get; set; }
        //public DbSet<Statistic> Statistics { get; set; }
        //public DbSet<StatisticsCompetition> StatisticsCompetitions { get; set; }
        //public DbSet<Webcontact> Webcontacts { get; set; }
        //public DbSet<WebcontactsCategory> WebcontactsCategories { get; set; }
        //public DbSet<Year> Years { get; set; }

        //public new IDbSet<T> Set<T>() where T : class
        //{
        //    return base.Set<T>();
        //}

        //public override int SaveChanges()
        //{
        //    this.ApplyStateChanges();
        //    return base.SaveChanges();
        //}

        #endregion

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new ArticleMap());
            modelBuilder.Configurations.Add(new ArticlesCategoryMap());
            modelBuilder.Configurations.Add(new CategoryMap());
            modelBuilder.Configurations.Add(new ClubMap());
            modelBuilder.Configurations.Add(new ClubsGroupMap());
            modelBuilder.Configurations.Add(new CompetitionMap());
            modelBuilder.Configurations.Add(new CompetitorMap());
            modelBuilder.Configurations.Add(new ContactMap());
            modelBuilder.Configurations.Add(new CountryMap());
            modelBuilder.Configurations.Add(new DisciplineListMap());
            modelBuilder.Configurations.Add(new DisciplineMap());
            modelBuilder.Configurations.Add(new DisciplinesGroupMap());
            modelBuilder.Configurations.Add(new DisciplinesStatusMap());
            modelBuilder.Configurations.Add(new DocumentMap());
            modelBuilder.Configurations.Add(new DocumentsCategoryMap());
            modelBuilder.Configurations.Add(new DocumentsSubcategoryMap());
            modelBuilder.Configurations.Add(new ExtTextMap());
            modelBuilder.Configurations.Add(new CheckPointMap());
            modelBuilder.Configurations.Add(new ChipDataMap());
            modelBuilder.Configurations.Add(new ChipTagMap());
            modelBuilder.Configurations.Add(new ChipTagsGroupMap());
            modelBuilder.Configurations.Add(new LinkMap());
            modelBuilder.Configurations.Add(new LinksCategoryMap());
            modelBuilder.Configurations.Add(new PerformanceMap());
            modelBuilder.Configurations.Add(new ResultCodeMap());
            modelBuilder.Configurations.Add(new StatisticMap());
            modelBuilder.Configurations.Add(new StatisticsCompetitionMap());
            modelBuilder.Configurations.Add(new WebcontactMap());
            modelBuilder.Configurations.Add(new WebcontactsCategoryMap());
            modelBuilder.Configurations.Add(new YearMap());

            modelBuilder.Entity<Category>().Ignore(t => t.ObjectState);
            modelBuilder.Entity<Competition>().Ignore(t => t.CompetitionInfo);
            modelBuilder.Entity<Competition>().Ignore(t => t.ObjectState);
            modelBuilder.Entity<Club>().Ignore(t => t.ObjectState);
            modelBuilder.Entity<Country>().Ignore(t => t.ObjectState);
            modelBuilder.Entity<Discipline>().Ignore(t => t.ObjectState);

            modelBuilder.Entity<DisciplineList>().Ignore(t => t.DisciplineListIcon);
            modelBuilder.Entity<DisciplineList>().Ignore(t => t.DisciplineListInfo);
            modelBuilder.Entity<DisciplineList>().Ignore(t => t.SubDisciplineList);
            modelBuilder.Entity<DisciplineList>().Ignore(t => t.ObjectState);

            modelBuilder.Entity<CheckPoint>().Ignore(t => t.ObjectState);
            modelBuilder.Entity<ChipTag>().Ignore(t => t.ObjectState);
            modelBuilder.Entity<Performance>().Ignore(t => t.ObjectState);
        }
    }
}
